package com.rfid.spec;

import java.util.Vector;
import java.util.concurrent.locks.ReentrantLock;

public class NetManager {
    private Vector<NetDataReport> m_TDReports = new Vector();
    private ReentrantLock m_syncTDReports = new ReentrantLock();
    long m_tagReportCursor = 0L;

    public boolean AddNewReport(NetDataReport newTDR, Boolean filtDuplicated) {
        boolean addok = false;
        boolean b_find = false;
        this.m_syncTDReports.lock();
        if (filtDuplicated.booleanValue()) for (int j = 0; j < this.m_TDReports.size(); j++) {
            NetDataReport p = (NetDataReport) this.m_TDReports.get(j);
            if (p != null && p.IsEqual(newTDR)) {
                b_find = true;
                break;
            }
        }
        if (!b_find) {
            this.m_TDReports.add(newTDR);
            addok = true;
        }
        this.m_syncTDReports.unlock();
        return addok;
    }

    public void DeleteAllReports() {
        this.m_tagReportCursor = 0L;
        this.m_syncTDReports.lock();
        if (!this.m_TDReports.isEmpty()) this.m_TDReports.clear();
        this.m_syncTDReports.unlock();
    }

    public void TRCInit() {
        this.m_syncTDReports.lock();
        this.m_tagReportCursor = 0L;
        if (!this.m_TDReports.isEmpty()) this.m_TDReports.clear();
        this.m_syncTDReports.unlock();
    }

    public boolean TRCMoveFirst() {
        if (this.m_TDReports.size() > 0) {
            this.m_tagReportCursor = 0L;
            return true;
        }
        this.m_tagReportCursor = 0L;
        return false;
    }

    public boolean TRCMoveNext() {
        if (this.m_tagReportCursor < this.m_TDReports.size()) {
            this.m_tagReportCursor++;
            return true;
        }
        return false;
    }

    public boolean TRCMoveLast() {
        if (this.m_TDReports.size() > 0) {
            this.m_tagReportCursor = (this.m_TDReports.size() - 1);
            return true;
        }
        this.m_tagReportCursor = 0L;
        return false;
    }

    public NetDataReport TRCGetReport() {
        if (this.m_tagReportCursor < 0L || this.m_tagReportCursor >= this.m_TDReports.size())
            return null;
        return (NetDataReport) this.m_TDReports.get((int) this.m_tagReportCursor);
    }

    public int GetTagReportCount() {
        return this.m_TDReports.size();
    }
}
